<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DoTest Runner</title>

<script type="text/javascript" src="DoTest.js"></script>
<script>
// type="text/javascript" src="lib1.js"
function getParameter(name) {
  var search = document.location.search;
  if (!search) {
    // This is for IE. IE cannot find file with search parameter for local file.
    search = document.location.hash;
  }
  if (search.length < 1) {
    return null;
  }
  // Omit the starting '?' or '#'.
  search = search.substring(1);
  name = encodeURIComponent(name) + "=";
  var args = search.split("&");
  for (var i = 0; i < args.length; ++i) {
    var arg = args[i];
    if (arg.length < name.length) {
      continue;
    }
    var beginning = arg.substring(0, name.length);
    if (beginning == name) {
      var value = decodeURIComponent(arg.substring(name.length));
      if (!isNaN(value)) {
        value = parseFloat(value);
      }
      return value;
    }
  }
  return null;
}

/**
 * @param search current search parameter, if empty, using the default.
 * @param shouldAddOrRemove whether to add the parameter when missing,
 *        or remove the parameter when value is empty.
 * @return the string with parameter replaced, without the leading '?' character.
 */
function getReplacedParameterString(search, name, value, shouldAddOrRemove) {
  if (!search) {
    search = document.location.search;
    if (!search) {
      // This is for IE. IE cannot find file with search parameter for local file.
      search = document.location.hash;
    }
    if (search.length < 1) {
      return "";
    }
    // Omit the starting '?' or '#'.
    search = search.substring(1);
  }
  name = encodeURIComponent(name) + "=";
  var args = search.split("&");
  var i = 0;
  for (; i < args.length; ++i) {
    var arg = args[i];
    if (arg.length < name.length) {
      continue;
    }
    var beginning = arg.substring(0, name.length);
    if (beginning == name) {
      break;
    }
  }
  if (i < args.length) {
    if (shouldAddOrRemove && !value) {
      args.splice(i, 1);
    } else {
      args[i] = beginning + encodeURIComponent(value);
    }
  } else {
    if (shouldAddOrRemove && value) {
      args.push(name + encodeURIComponent(value));
    }
  }
  return args.join("&");
}
</script>
<style>
</style>
</head>
<body>

<p>If there is no alerts, tests passed.</p>

<p>
OPTION: [ <a id="linkTest" href="DoTest.html">none</a>
| <a id="linkTest_showAssert" href="DoTest.html?showAssert=1">showAssert</a>
| <a id="linkTest_usingThrow" href="DoTest.html?usingThrow=1">usingThrow</a>
];
Quirks Mode: [ <a id="linkTestQuirks" href="DoTestQuirks.html">none</a>
| <a id="linkTestQuirks_showAssert" href="DoTestQuirks.html?showAssert=1">showAssert</a>
| <a id="linkTestQuirks_usingThrow" href="DoTestQuirks.html?usingThrow=1">usingThrow</a>
]</p>

<pre>
<script type="text/javascript">
function runAll() {
  if (getParameter('showAssert')) {
    window.DoTest_showAssert = true;
  }
  if (getParameter('usingThrow')) {
    window.DoTest_usingThrow = true;
  }
  if (getParameter('includes')) {
    window.DoTest_includes += ',' + getParameter('includes') + ',';
  }
  if (getParameter('excludes')) {
    window.DoTest_excludes += ',' + getParameter('excludes') + ',';
  }
  var filesParam = getParameter('files') || '';
  if (filesParam) {
    document.title = filesParam;
    // Update top window's title, so that the history list is more readable.
    try {
      if (window != window.top) {
        window.top.document.title = filesParam;
      }
    } catch (ignored) {
    }

    var paramString = getReplacedParameterString('', 'files', filesParam, true);
    var plainParamString = paramString;
    plainParamString = getReplacedParameterString(plainParamString, 'showAssert', '', true);
    plainParamString = getReplacedParameterString(plainParamString, 'usingThrow', '', true);
    var paramString_showAssert = getReplacedParameterString(paramString, 'showAssert', '1', true);
    var paramString_usingThrow = getReplacedParameterString(paramString, 'usingThrow', '1', true);

    document.getElementById('linkTest').href = 'DoTest.html' + '?' + plainParamString;
    document.getElementById('linkTest_showAssert').href = 'DoTest.html' + '?' + paramString_showAssert;
    document.getElementById('linkTest_usingThrow').href = 'DoTest.html' + '?' + paramString_usingThrow;
    document.getElementById('linkTestQuirks').href = 'DoTestQuirks.html' + '?' + plainParamString;
    document.getElementById('linkTestQuirks_showAssert').href = 'DoTestQuirks.html' + '?' + paramString_showAssert;
    document.getElementById('linkTestQuirks_usingThrow').href = 'DoTestQuirks.html' + '?' + paramString_usingThrow;
  }

  var files = filesParam.split(',');
  for (var i = 0; i < files.length; ++i) {
    if (!files[i])
      continue;
    var s = '<' + 'script type="text/javascript" src="' + files[i] + '"></' + 'script>';
    document.writeln(files[i]);
    document.write(s);
  }
}

document.writeln("Date=" + new Date());
runAll();
document.writeln("Date=" + new Date());
</script>

</pre>

</body>
</html>
